<!DOCTYPE html>
<html lang="zh">

<head>
    <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
    <meta http-equiv="X-UA-Compatible" content="IE=edge" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0, user-scalable=0, minimal-ui" />
    <meta name="author" content="yinq" />
    <title>后台登录</title>
    <link rel="shortcut icon" type="image/x-icon" href="favicon.ico" />
    <meta name="apple-mobile-web-app-capable" content="yes" />
    <meta name="apple-touch-fullscreen" content="yes" />
    <meta name="apple-mobile-web-app-status-bar-style" content="default" />
    <link rel="stylesheet" type="text/css" href="/static/css/materialdesignicons.min.css" />
    <link rel="stylesheet" type="text/css" href="/static/css/bootstrap.min.css" />
    <link rel="stylesheet" type="text/css" href="/static/css/animate.min.css" />
    <link rel="stylesheet" type="text/css" href="/static/css/style.min.css" />
    <style>
        .login-form .has-feedback {
            position: relative;
        }

        .login-form .has-feedback .form-control {
            padding-left: 36px;
        }

        .login-form .has-feedback .mdi {
            position: absolute;
            top: 0;
            left: 0;
            right: auto;
            width: 36px;
            height: 36px;
            line-height: 36px;
            z-index: 4;
            color: #dcdcdc;
            display: block;
            text-align: center;
            pointer-events: none;
        }

        .login-form .has-feedback.row .mdi {
            left: 15px;
        }
    </style>
</head>

<body class="center-vh" style="background-image: url(/static/images/login-bg-3.jpg); background-size: cover">
    <div class="card card-shadowed p-5 w-420 mb-0 mr-2 ml-2">
        <div class="text-center mb-3">
            <h3>软盒后台管理</h3>
        </div>

        <form class="login-form">
            <div class="form-group has-feedback">
                <span class="mdi mdi-account" aria-hidden="true"></span>
                <input type="text" class="form-control" name="adminname" placeholder="用户名" />
            </div>

            <div class="form-group has-feedback">
                <span class="mdi mdi-lock" aria-hidden="true"></span>
                <input type="password" class="form-control" name="adminpass" placeholder="密码" />
            </div>

            <div class="form-group has-feedback row">
                <div class="col-7">
                    <span class="mdi mdi-check-all form-control-feedback" aria-hidden="true"></span>
                    <input type="text" name="captcha" class="form-control" placeholder="验证码" />
                </div>
                <div class="col-5 text-right">
                    <img src="{:captcha_src()}" class="pull-right" id="captcha" style="cursor: pointer"
                        onclick="this.src=this.src+'?d='+Math.random();" title="点击刷新" alt="captcha" />
                </div>
            </div>

            <div class="form-group">
                <div class="custom-control custom-checkbox">
                    <input type="checkbox" class="custom-control-input" id="rememberme" name="rememberme" />
                    <label class="custom-control-label not-user-select" for="rememberme">5天内自动登录</label>
                </div>
            </div>

            <div class="form-group">
                <button class="btn btn-block btn-primary" type="submit" id="login">
                    立即登录
                </button>
            </div>
        </form>

        <p class="text-center text-muted mb-0">
            Copyright © 2022 <a href="http://www.ruanher.com">软盒</a>. All
            right reserved
        </p>
    </div>

    <script type="text/javascript" src="/static/js/jquery.min.js"></script>
    <script type="text/javascript" src="/static/js/lyear-loading.js"></script>
    <script type="text/javascript" src="/static/js/main.min.js"></script>
    <script type="text/javascript" src="/static/layui/notify_stand.js"></script>
    <script type="text/javascript">
        $("#login").click(function () {
            var l = $('body').lyearloading({
                opacity: 0.2,
                spinnerSize: 'lg'
            });
            $.ajax({
                url: "{:url('login/index')}",
                type: 'post',
                data: $("form").serialize(),
                dataType: 'json',
                success: function (data) {
                    l.destroy();
                    if(data.code == 1){
                        notify.success("登录成功",function(){
                            location.href = data.url;
                        },1000);
                    }else{
                        $("#captcha").click();
                        notify.error(data.msg);
                    }
                },
                error:function(){
                    l.destroy();
                    notify.error("服务器错误");
                }
            })
            return false;
        })
    </script>
</body>

</html>